package com.hex.ds.hdrs.period.task.converter;

import com.hex.ds.hdrs.common.utils.BaseUtil;
import com.hex.ds.hdrs.common.utils.HdrsDateUtil;
import com.hex.ds.hdrs.period.job.dto.PeriodJobTaskDto;
import com.hex.ds.hdrs.period.task.dto.PeriodTaskDefDto;
import com.hex.ds.hdrs.period.task.po.PeriodTaskDef;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

@Mapper(componentModel = "spring", imports = {BaseUtil.class, HdrsDateUtil.class})
public interface IPeriodTaskDefConverter {

    @Mappings({
            @Mapping(target = "priorityLevel", source = "periodJobTaskDto.sortNo")
    })
    PeriodTaskDefDto toPeriodTaskDefDto(PeriodJobTaskDto periodJobTaskDto, String appCode);

    @Mappings({
            @Mapping(target = "pkId", expression = "java(BaseUtil.getPkId())"),
            @Mapping(target = "crtTs", expression = "java(HdrsDateUtil.getCurrentTime())"),
            @Mapping(target = "upTs", expression = "java(HdrsDateUtil.getCurrentTime())")
    })
    PeriodTaskDef toPeriodTaskDefForAdd(PeriodTaskDefDto periodTaskDefDto);

    @Mappings({
            @Mapping(target = "upTs", expression = "java(HdrsDateUtil.getCurrentTime())")
    })
    PeriodTaskDef toPeriodTaskDefForModify(PeriodTaskDefDto periodTaskDefDto);

}
